<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        div {
            position: relative;
            margin: 100px auto;
            width: 200px;
            height: 200px;
            background-color: pink;
            text-align: center;
            line-height: 200px;
        }
        
        span {
            position: absolute;
            top: 0;
            right: 0;
            width: 10px;
            height: 10px;
            background-color: red;
        }
        
        .spanclick {
            display: none;
        }
    </style>
</head>

<body>
    <div>
        我是广告
        <span></span>
    </div>
    <script>
        var div = document.querySelector('div');
        var span = document.querySelector('span');
        span.onclick = function() {
            span.className = 'spanclick';
            div.className = 'spanclick';
        }
    </script>
</body>

</html>